package com.yiwei.app.modules.controller;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yiwei.app.common.utils.ResultEntity;
import com.yiwei.app.modules.entity.OrderInfo;
import com.yiwei.app.modules.service.OrderService;

@Controller
public class SettlementController {


		 @Autowired
		 private OrderService orderService;
		  ResultEntity result=new ResultEntity();
		 @ResponseBody
		 @RequestMapping(value="saveOrderInfo",method=RequestMethod.POST)
		 public ResultEntity saveOrderInfo(OrderInfo orderInfo,String areaId){
			           
			       boolean flag = orderService.insertorderInfo(orderInfo);
			       
			       if(flag){
			    	   result.setCode("101");
			    	   result.setMessage("成功保存数据");
			    	   return result;
			       }
			       result.setCode("500");
			       result.setMessage("保存数据库失败");
			 return result;
		 }
		 @RequestMapping(value="selectOrderById",method=RequestMethod.GET)
		  public OrderInfo selectByOrderInfoId(String delFlag,String id){
			OrderInfo orderInfo = orderService.selectbyOrderInfoId(id);
		    return orderInfo;
		  }
		 @ResponseBody
		 @RequestMapping(value="updateOrderInfo",method=RequestMethod.POST)
		 public ResultEntity updateOrderInfo(OrderInfo orderInfo){
			           boolean flag = orderService.updateorderInfo(orderInfo);
			           if(flag){
			        	   result.setCode("101");
			        	   result.setMessage("更新订单信息成功");
			        	   return result;
			           }
			           result.setCode("500");
			           result.setMessage("更新订单信息失败");
			           return result;
		 }
		 @ResponseBody
		 @RequestMapping(value="delete",method=RequestMethod.GET)
		 public ResultEntity deleteOrderInfo(String delFlag,String id){
			        boolean flag = orderService.deleteDeliveryOrderbyiId(delFlag, id);
			        if(flag){
			        	result.setCode("101");
			        	result.setMessage("订单信息删除成功");
			        	return result;
			        }
			        result.setCode("500");
			        result.setMessage("订单信息删除失败");
			        return result;
		 }
		 @ResponseBody
		 @RequestMapping(value="selectOrderInfo",method=RequestMethod.GET)
		 public List selectOrderInfo(String pageNum,String pageSize){
			 List list = orderService.selectOrderInfoList(pageNum, pageSize);
			 return list;
		 }
	}

